<template>
  <el-dialog v-dialogDrag v-if=" popenevTVisible " title="流程发送" :visible.sync=" popenevTVisible " :before-close=" handleCancel" width="820px" :close-on-click-modal=" false ">
    <!-- 流程可选节点 -->
    <!-- {{this.$store.state.flow.sendForm}} -->
    <div class="flow-node-list">
      <el-radio-group :disabled="isLoading" v-model=" getPersonParams.nodeId " @change=" flowNodeChange " size="medium">
        <el-radio v-for="( item, index ) in flowBranceOptions" :key=" index " :label=" item.nodeId ">
          <span :title="item.remark || item.nodeName">{{ item.nodeName }}</span>
        </el-radio>
      </el-radio-group>
    </div>
    <!-- 提示信息 -->
    <div class="tip-info">
      <span v-if=" this.tips.secretLevels ">当前办理人密级：{{ this.tips.secretLevels }};</span>
      <span v-if=" this.tips.blrbm ">当前办理人部门：{{ this.tips.blrbm }};</span>
      <span v-if=" this.tips.blrjs ">当前办理人角色：{{ this.tips.blrjs }};</span>
      <span v-if=" this.tips.zdblr ">当前办理人：{{ this.tips.zdblr }}</span>
    </div>
    <div class="choice-person-box">
      <!-- 机构 -->
      <div class="org-list">
        <!-- 搜索框 -->
        <el-input size="mini" class="org-search" placeholder="搜索" v-model=" searchoOrgkey ">
          <i slot="prefix" class="el-input__icon el-icon-search"></i>
        </el-input>
        <el-scrollbar class="scorll-Y">
          <el-tree class="filter-tree" :data=" treeData " :props=" { label: 'orgCommonname', isLeaf: 'leaf' } " node-key="unid" :default-expanded-keys=" expandedKey " :load="loadOrgNode" :lazy="orgLazy" :expand-on-click-node=" false " :highlight-current=" true " :check-on-click-node=" true " :check-strictly=" true " @check-change=" handleOrgChange " :filter-node-method=" filterOrgNode " ref="orgTree">
          </el-tree>
          <!-- <div class="extend_people">
            <div class="send_group_title">常用联系人</div> 
            <a-tree
              class="draggable-tree"
              @select="groupOnSelect"
              :replaceFields="{children:'children', title:'name', key:'unid', value: 'unid'}"
              :tree-data="groupData">
              </a-tree>
           </div> -->
        </el-scrollbar>
      </div>
      <!-- 人员列表 -->
      <div class="person-list" style="margin-left:10px">
        <!-- 搜索框 -->
        <div style="display: flex;align-items: center;">
          <el-checkbox style="margin-top:20px;margin-left:10px" :indeterminate=" isIndeterminate " v-model=" checkAll " @change=" handleCheckAllChange ">全选</el-checkbox>
          <el-input class="search-input" placeholder="搜索" size="mini" v-model=" searchoPersonKey ">
            <i slot="prefix" class="el-input__icon el-icon-search"></i>
          </el-input>
        </div>
        <el-scrollbar class="scorll-Y">
          <div v-if="isShowGroup && grounpTreeData.length > 0">
            <el-tree class="filter-tree" :data="grounpTreeData" :props=" { label: 'name' } " node-key="unid" :expand-on-click-node=" false " :highlight-current=" true " :check-on-click-node=" true " :check-strictly=" true " @check-change=" handleGrounpChange " :filter-node-method="filterGrounpNode" ref="grounpTree">
              <span class="custom-tree-node" slot-scope="{ node,data }">
                <span>{{ node.label }}(群组)</span>
              </span>
            </el-tree>
          </div>
          <el-checkbox-group v-model=" personUnidArr " size="medium">
            <el-checkbox class="person-item" @change=" onChangePerson " v-for="( pre_item, index ) in showPersonData" :label=" pre_item.unid + '_' + pre_item.sendNodeName + '_' + pre_item.personCommonname + '_' + pre_item.shortname " :key=" index "><span class="person-item-text">{{ pre_item.personCommonname }}</span></el-checkbox>
          </el-checkbox-group>
        </el-scrollbar>
      </div>
      <!-- 人员列表 -->
      <div class="person-list" style="margin-left:10px">
        <div class="search-input" style="line-height:32px;font-weight: 700">
          已选人员({{checkPerosnList.length}})
          <el-button type="text" @click=" handelEmpty ">清空</el-button>
        </div>
        <el-scrollbar class="scorll-Y">
          <div class="person-item" v-for="( pre_item, index ) in checkPerosnList" :key=" index ">
            {{ pre_item.personCommonname }}[{{ pre_item.sendNodeName }}]
            <span v-if="tips.blsx && tips.blsx != '0'">({{tips.blsx}}小时)</span>
            <i class="btn-person-cacle el-icon-circle-close" @click=" handleDelPerson( pre_item ) " />
          </div>
        </el-scrollbar>
      </div>

      <!-- <div class="person-list" v-loading="isLoading">
        <el-transfer size="mini" style="text-align: left; display: inline-block" v-model="personUnidArr" filterable :filter-method="filterMethod" :titles="['人员列表', '选择人员']" :button-texts="['取消', '选择']" @change="handleChange" :data="personData" :props="{
            key: 'unid',
            label: 'personCommonname',
          }">
          <span slot-scope="{ option }" @dblclick="handleDoubleClick(option)">{{ option.personCommonname }}<template v-if="personUnidArr.indexOf(option.unid) > -1">[{{option.sendNodeName}}]</template></span>
        </el-transfer>
      </div> -->
    </div>
    <div class="msg-check" v-show=" VUE_APP_USE_NET_NOTIFY ">
      <el-checkbox v-model=" msgSend " v-if=" isShowMsgTip ">短信提醒</el-checkbox>
      <el-checkbox v-model=" netSend " v-if=" isShowNetwork ">网络消息</el-checkbox>
    </div>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" :loading=" confirmLoading " @click=" handleOk ">{{ btnText }}</el-button>
      <el-button @click=" handleCancel ">取 消</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { getFlowPerson, flowOrg, getOrgListByParentId } from "../../api/module/systemPerson/systemPerson";
import
{
  getSendFlowNode,
  sendDoc
} from "../../api/common/flowsend";
import { writeNotion } from "../../api/common/flowsend";
import { getNodeId } from "../../api/common/getNodeId";
import { mapGetters, mapMutations } from "vuex";
import { formatDate } from "../../utils/index";
import request from '@/utils/request';
import PinYinMatch from "pinyin-match";
import { sha256 } from 'js-sha256'
import { Loading } from 'element-ui'
import { getList as getToDoList } from "../../api/module/grbg/todoList";
export default {
  data()
  {
    return {
      isShowGroup: window.HC_config.VUE_APP_SHOW_GROUP,//是否群组
      btnText: window.HC_config.APP_VUE_SEND_TEXT || "发送",
      //发送框是否显示网络消息
      VUE_APP_USE_NET_NOTIFY: window.HC_config.VUE_APP_USE_NET_NOTIFY || false,
      //是否启用网络连接
      isShowNetwork: window.HC_config.VUE_OPEN_WEBSOCKET || false,
      //短信消息
      msgSend: window.HC_config.VUE_APP_CHECKMSG || false,
      //网咯消息
      netSend: window.HC_config.VUE_APP_CHECKNET || false,
      //是否显示短信提示
      isShowMsgTip: window.HC_config.VUE_APP_USE_SMS_NOTIFY,
      isLoading: false,
      //是否加载中
      confirmLoading: false,
      //流程分支
      flowBranceOptions: [],
      popenevTVisible: false,
      multiple: false,
      treeData: [], //机构列表
      personData: [], //人员列表
      expandedKey: [],
      //promise 状态
      promiseStatus: null,
      searchoOrgkey: "", //机构搜索
      searchoPersonKey: "",//人员搜索
      searchkey: "",
      searchoGroupkey: "",//群组搜索
      grounpTreeData: [],//群组数据      
      personUnidArr: [],
      //提示信息
      tips: {},
      //查询人员参数
      getPersonParams: {
        //节点id
        nodeId: null,
        //流程id
        flowId: null,
        //部门id
        orgUnid: "",
        //保密等级
        secretLevel: null,
      },
      //indeterminate 属性用以表示 checkbox 的不确定状态，一般用于实现全选的效果
      isIndeterminate: true,
      //是否全选
      checkAll: false,
      //流程节点unid
      flowstructureunid: null,
      //发送节点名称
      sendNodeName: null,
      //模块名
      moduleName: null,
      //表单名
      formType: null,
      //表单的unid
      formUnid: null,
      //0串行和2单选
      multi: 0,
      //暂存排序分组数据
      groupDataObj: {},
      //阅文意见类型
      notionType: null,
      //是否是代签意见
      dlyj: false,
      //是否为共享意见
      gxyj: false,
      //是否直接发送
      sfzjfs: false,
      //是否排除本人
      sfpcbr: false,
      //是否完成其他人未完成的人
      finalizeUnFinishTasks: false,
      //机构懒加载
      orgLazy: window.HC_config.VUE_APP_ORGLAZY
    };
  },
  computed: {
    ...mapGetters(["userInfo"]),
    showPersonData()
    {
      if (!this.searchoPersonKey)
      {
        return this.personData;
      }
      else
      {
        let tampPersonArr = [];
        this.personData.forEach(pre_item =>
        {
          if (PinYinMatch.match(pre_item.personCommonname, this.searchoPersonKey))
          {
            tampPersonArr.push(pre_item);
          }
        })
        return tampPersonArr;
      }
    },
    checkPerosnList()
    {
      let tampList = [];
      this.personUnidArr.map(pre_unid =>
      {
        let personInfoArr = pre_unid.split("_");
        tampList.push({
          unid: personInfoArr[0],
          sendNodeName: personInfoArr[1],
          personCommonname: personInfoArr[2],
          shortname: personInfoArr[3]
        });
      })
      console.log(tampList);
      return tampList;
    }
  },
  watch: {
    searchoOrgkey(val)
    {
      this.$refs.orgTree.filter(val);
    },
    //群组搜索
    searchoGroupkey(val)
    {
      this.$refs.grounpTree.filter(val);
    }
  },
  methods: {
    ...mapMutations("user", ["SET_DBSXNUM"]),
    //过滤机构
    filterOrgNode(value, data)
    {
      if (!value) return true;
      return PinYinMatch.match(data.orgCommonname, value);
    },
    //过滤群组
    filterGrounpNode(value, data)
    {
      if (!value) return true;
      return PinYinMatch.match(data.name, value);
    },
    //人员过滤
    filterMethod(query, item)
    {
      if (!query)
      {
        return true;
      }
      return PinYinMatch.match(item.personCommonname, query);
    },
    //获取流程可选节点数据
    getSendFlowNode()
    {
      getSendFlowNode(this.moduleName, this.formUnid, this.formType).then(res =>
      {
        this.flowBranceOptions = res.result.nodes || [];
        this.multi = res.result.multi;
        if (this.flowBranceOptions.length > 0)
        {
          //默认勾选第一项
          this.getPersonParams.nodeId = this.flowBranceOptions[0].nodeId;
          this.getPersonParams.flowId = this.flowBranceOptions[0].flowId;
          this.sendNodeName = this.flowBranceOptions[0].nodeName;
          this.getPersonParams.unid = this.formUnid;
          if (this.orgLazy)
          {
            this.getFlowOrg(this.getPersonParams);
          }
          else
          {
            this.getFlowPerson(this.getPersonParams, this.moduleName);
          }
        }
      })
    },
    /**
    * 获取当前登录人最新阅文意见
     */
    getNodeId()
    {
      if (this.notionType && this.dlyj != 1)
      {
        getNodeId({ unid: this.formUnid, type: this.notionType }).then((res) =>
        {
          console.log(res)
          if (res.result && res.result.dlyj)
          {
            let currentNotion = res.result;
            //将代签意见改为false
            writeNotion({
              notionContent: currentNotion.content,
              moduleName: this.moduleName,
              docIdent: this.formUnid,
              notionType: this.notionType,
              dlyj: false,
              published: currentNotion.published,
              sslb: "",
              gxyj: currentNotion.gxyj,
              flowstructureunid: this.flowstructureunid,
            }).then(res =>
            {

            })
          }
        });
      }
    },
    //获取部门的人员数据
    getFlowPerson(params)
    {
      this.isLoading = true;
      getFlowPerson(params)
        .then((res) =>
        {
          this.isLoading = false;

          this.personData = res.result.persons || [];
          this.grounpTreeData = res.result.groupList || [];

          //提示信息
          this.tips = res.result;
          if (!this.orgLazy)
          {
            this.treeData = res.result.orgTree || [];
            this.treeData.unshift({
              unid: "",
              orgCommonname: "<所有人员>"
            })
            if (!this.getPersonParams.orgUnid)
            {
              this.treeData.forEach((element) =>
              {
                this.expandedKey.push(element.unid);
              });
            }
            else
            {
              this.expandedKey = [this.getPersonParams.orgUnid];
            }
          }

          if (!this.sfzjfs)
          {
            this.$nextTick(() =>
            {
              this.$refs.orgTree.setCurrentKey(this.getPersonParams.orgUnid);
            })

            this.$nextTick(() =>
            {
              if (this.$refs.grounpTree)
              {
                this.$refs.grounpTree.setCurrentKey(this.getPersonParams.groupUnid);
              }
            })
          }

          let distinctArrMap = {};
          const newArr = [];
          this.personData.forEach((item) =>
          {
            item.key = item.unid;
            item.title = item.personCommonname;
            if (!item.sendNodeName)
            {
              item.sendNodeName = this.sendNodeName;
            }
            if (!distinctArrMap[item.unid])
            {
              distinctArrMap[item.unid] = item;
              newArr.push(item);
            }
          });
          this.personData = newArr;

          this.personData.map(per_item =>
          {
            let tampStr = per_item.unid + "_" + per_item.sendNodeName + "_" + per_item.personCommonname + '_' + per_item.shortname;
            if (this.personUnidArr.indexOf(tampStr) === -1)
            {
              this.checkAll = false
            }
            else
            {
              this.checkAll = true
            }
          })
          if (this.sfpcbr)
          {
            this.personData = this.personData.filter(v => v.unid != this.userInfo.unid)
          }

          if (window.HC_config.VUE_APP_DEFAULT_CHECK && this.tips.blrjs)
          {
            this.personData.map(per_item =>
            {
              let tampStr = per_item.unid + "_" + per_item.sendNodeName + "_" + per_item.personCommonname + '_' + per_item.shortname;
              this.personUnidArr.push(tampStr);
            })
          }
          //群组人员直接勾选
          if (this.getPersonParams.groupUnid)
          {
            if (this.personData.length >= 1)
            {
              this.personUnidArr = [];
              this.personData.forEach((pre_item, pre_index) =>
              {
                let P_PersonItem = this.personData[pre_index];
                this.personUnidArr[pre_index] = P_PersonItem.unid + "_" + P_PersonItem.sendNodeName + "_" + P_PersonItem.personCommonname + '_' + P_PersonItem.shortname;
              })
            }
          }

          //节点勾选直接发送
          if (this.sfzjfs)
          {
            if (this.personData.length >= 1)
            {
              this.personUnidArr = [];
              this.personData.forEach((pre_item, pre_index) =>
              {
                let P_PersonItem = this.personData[pre_index];
                this.personUnidArr[pre_index] = P_PersonItem.unid + "_" + P_PersonItem.sendNodeName + "_" + P_PersonItem.personCommonname + '_' + P_PersonItem.shortname;
              })

              this.handleOk();
              // this.$confirm(`确定要发送给${P_PersonItem.personCommonname}吗?`, "提示", {
              //   confirmButtonText: "确定",
              //   cancelButtonText: "取消",
              //   type: "warning",
              // }).then(res =>
              // {
              //   this.handleOk();
              // })
            }
          }

        })
        .catch((e) =>
        {
          console.log(e);

          this.isLoading = false;
        });
    },
    //获取部门数据
    getFlowOrg(params)
    {
      this.isLoading = true;
      flowOrg(params)
        .then((res) =>
        {
          this.isLoading = false;
          //提示信息
          this.tips = res.result;
          this.treeData = res.result.orgTree || [];

          if (this.treeData.length == 0)
          {
            this.getFlowPerson(params);
          }
          else
          {
            this.treeData.forEach(pre_org =>
            {
              pre_org.leaf = pre_org.subOrgNum && pre_org.subOrgNum > 0 ? false : true;
            })
          }
        })
        .catch((e) =>
        {
          console.log(e);

          this.isLoading = false;
        });
    },
    //监听节点变化
    flowNodeChange(e)
    {
      //重置部分数据
      this.searchkey = "";
      // 串行和单送清空，并行保留
      if (this.multi == 0 || this.multi == 2)
      {
        this.personUnidArr = [];
      }
      this.sendNodeName = e;
      // 切换节点时清空机构选中状态
      this.getPersonParams.orgUnid = "";
      this.getPersonParams.groupUnid = null;
      if (this.orgLazy)
      {
        this.getFlowOrg(this.getPersonParams);
      }
      else
      {
        this.getFlowPerson(this.getPersonParams, this.moduleName);
      }
    },
    show(showData)
    {
      console.log(showData, 'showData')
      this.moduleName = showData.moduleName;
      this.formType = showData.formType;
      this.formUnid = showData.unid;
      this.flowstructureunid = showData.flowstructureunid,
        console.log(showData);
      this.finalizeUnFinishTasks = showData.finalizeUnFinishTasks;
      this.notionType = showData.notionType;
      this.dlyj = showData.dlyj || false;
      this.sfzjfs = showData.sfzjfs || false;
      this.sfpcbr = showData.sfpcbr || false;
      //密级
      this.getPersonParams.secretLevel = showData.mj;
      this.getSendFlowNode();

      //是紧急文件
      if (showData.isJjwj != "" && showData.isJjwj != null)
      {
        this.netSend = true;
      }

      if (!this.sfzjfs)
      {
        this.popenevTVisible = true;
      }

      // 创建promise
      return new Promise((resolve, reject) =>
      {
        this.promiseStatus = {
          resolve,
          reject,
        };
      });
    },
    //流程发送事件处理
    cycleHandleOk()
    {
      let sendEventList = this.$store.state.flow.sendForm || [];
      //  let sendEventList=this.$store.state.project.sendFormList||[];
      if (sendEventList.length > 0)
      {
        this.circleHandleOk(sendEventList, 0)
      } else
      {
        this.handleOk();
      }
    },
    //删除人员
    handleDelPerson(P_PersonItem)
    {
      let tampIndex = this.personUnidArr.findIndex(pre_item =>
      {
        return pre_item == P_PersonItem.unid + "_" + P_PersonItem.sendNodeName + "_" + P_PersonItem.personCommonname + '_' + P_PersonItem.shortname;
      })
      this.personUnidArr.splice(tampIndex, 1);
    },
    //
    singleHandleOk(item)
    {
      let formUnid = item.id || 0;
      //消息模式
      let awakeMode = 0;
      if (this.msgSend == true && this.netSend == true)
      {
        awakeMode = 65535
      } else
      {
        if (this.msgSend == true)
        {
          awakeMode = 2
        }
        if (this.netSend == true)
        {
          awakeMode = 1
        }
      }
      if (this.checkPerosnList.length < 1)
      {
        this.$message.error("请选择发送的人员！");
        return;
      }



      let targetNodesWithUser = this.getTargetNodesWithUser();
      const urlparam = {
        flowstructureunid: this.flowstructureunid,
        P_Unid: formUnid,
        unid: formUnid,
        awakeMode: awakeMode,
        // backlogUrl: this.moduleurl,
        bt: "",
        backlogUrl: this.$route.path,
        finalizeUnFinishTasks: this.finalizeUnFinishTasks,
        moduleName: this.moduleName,
        openBacklogTarget: "_blank",
        senderUser: "1",
        targetNodesWithUser: JSON.stringify(targetNodesWithUser),
        sslb: this.formType ? this.formType : "",
      };

      this.confirmLoading = true;
      sendDoc(urlparam)
        .then((res) =>
        {
          this.$message.success("发送成功");
          this.destroyElement();
          //cs 2022-9-30 发送消息到即时通讯工具
          if (window.HC_config.VUE_APP_ISSEND_QD)
          {
            this.sendMessageQd(this.checkPerosnList);
          }
          this.promiseStatus.resolve(this.sendNodeName);
          // this.$emit("ok", this.sendNodeName);
        })
        .catch((err) =>
        {
          console.log(err);
        })
        .finally(() =>
        {
          this.confirmLoading = false;
        });
    },
    //特殊发送事件处理
    circleHandleOk(arr, index)
    {
      for (var i = 0; i < arr.length; i++)
      {
        let item = arr[i];
        this.singleHandleOk(item);
      }
    },
    //懒加载机构节点
    loadOrgNode(node, resolve)
    {
      let parentUnid = null;
      if (node.level === 0)
      {
        resolve([]);
      }
      else
      {
        parentUnid = node.data.unid
        getOrgListByParentId({
          parentUnid: parentUnid,
          zdblrbmUnid: this.tips.strZdblrbmUnid
        }).then(res =>
        {
          let orgList = res.result || [];
          orgList.forEach(pre_org =>
          {
            pre_org.leaf = pre_org.subOrgNum && pre_org.subOrgNum > 0 ? false : true;
          })
          resolve(orgList);
        })
      }
    },
    handleOk()
    {
      //消息模式
      let awakeMode = 0;
      if (this.msgSend == true && this.netSend == true)
      {
        awakeMode = 65535
      } else
      {
        if (this.msgSend == true)
        {
          awakeMode = 2
        }
        if (this.netSend == true)
        {
          awakeMode = 1
        }
      }
      if (this.checkPerosnList.length < 1)
      {
        this.$message.error("请选择发送的人员！");
        return;
      }



      let targetNodesWithUser = this.getTargetNodesWithUser();
      const urlparam = {
        flowstructureunid: this.flowstructureunid,
        P_Unid: this.formUnid,
        unid: this.formUnid,
        awakeMode: awakeMode,
        // backlogUrl: this.moduleurl,
        bt: "",
        backlogUrl: this.$route.path,
        finalizeUnFinishTasks: this.finalizeUnFinishTasks,
        moduleName: this.moduleName,
        openBacklogTarget: "_blank",
        senderUser: "1",
        targetNodesWithUser: JSON.stringify(targetNodesWithUser),
        sslb: this.formType ? this.formType : "",
        gxyj: (sessionStorage.getItem('gxyj') == 'true')
      };
      this.confirmLoading = true;
      let requestLoading = null;
      if (this.sfzjfs)
      {
        requestLoading = Loading.service({ text: "", spinner: "el-icon-loading", background: "rgba(0, 0, 0, 0.1)", })
      }
      sendDoc(urlparam)
        .then((res) =>
        {
          this.$message.success("发送成功");
          // this.getNodeId();
          this.destroyElement();
          //cs 2022-9-30 发送消息到即时通讯工具
          if (window.HC_config.VUE_APP_ISSEND_QD)
          {
            this.sendMessageQd(this.checkPerosnList);
          }
          //刷新用户待办事项
          this.reloadDbsx();
          this.promiseStatus.resolve(this.sendNodeName);
          // this.$emit("ok", this.sendNodeName);
        })
        .catch((err) =>
        {
          console.log(err);
        })
        .finally(() =>
        {
          this.confirmLoading = false;
          requestLoading && requestLoading.close();
        });
    },
    handleCancel()
    {
      //清空勾选项
      this.promiseStatus.reject({
        msg: "取消",
      });
      this.destroyElement();
    },
    //清空已选项
    handelEmpty()
    {
      this.personUnidArr = [];
    },
    /*
     * cs 2022-3-3
     * 从checkPerosnList 中 取unid
     * 返回值 {"部门":[1212,121212]}
     */
    getTargetNodesWithUser()
    {
      let tampObj = {};
      this.checkPerosnList.forEach(item =>
      {
        if (tampObj[item.sendNodeName])
        {
          tampObj[item.sendNodeName].push(item.unid);
        } else
        {
          tampObj[item.sendNodeName] = [];
          tampObj[item.sendNodeName].push(item.unid);
        }
      })
      return tampObj;
    },
    // 机构变化
    handleOrgChange(data, check, tree)
    {
      if (this.getPersonParams.orgUnid != data.unid)
      {
        console.log("-------机构变化-------")
        this.getPersonParams.groupUnid = null;
        this.getPersonParams.orgUnid = data.unid;
        this.getFlowPerson(this.getPersonParams, this.moduleName);
      }
    },
    // 群组变化
    handleGrounpChange(data, check, tree)
    {
      if (this.getPersonParams.groupUnid != data.unid)
      {
        this.getPersonParams.groupUnid = data.unid;
        this.getFlowPerson(this.getPersonParams, this.moduleName);
      }
    },
    //监听人员选择
    onChangePerson(isAdd, e)
    {
      console.log(this.personUnidArr)
    },
    //全选或取消全选
    handleCheckAllChange(val)
    {
      if (val)
      {
        //全选
        this.showPersonData.map(per_item =>
        {
          let tampStr = per_item.unid + "_" + per_item.sendNodeName + "_" + per_item.personCommonname + '_' + per_item.shortname;
          if (this.personUnidArr.indexOf(tampStr) === -1)
          {
            this.personUnidArr.push(tampStr);
          }
        })
      }
      else
      {
        //取消全选
        this.showPersonData.map(per_item =>
        {
          let tampStr = per_item.unid + "_" + per_item.sendNodeName + "_" + per_item.personCommonname + '_' + per_item.shortname;
          let tampIndex = this.personUnidArr.indexOf(tampStr);
          this.personUnidArr.splice(tampIndex, 1);
        })
      }
      this.isIndeterminate = false;
    },
    /**
     * cs 2022-4-8
     * 销毁组件
     */
    destroyElement()
    {
      this.popenevTVisible = false;
    },
    //发送
    sendMessageQd(p_PersonArr)
    {
      let appid = '1664178824';
      let appsecret = '63795aacc229408';
      let timestamp = Math.round(new Date().getTime() / 1000).toString();
      let text = appid + appsecret + timestamp;
      let authen = sha256(text).toString();

      let _headers = {
        "Content-Type": "application/json; charset=UTF-8",
        "authen": authen,
        "appid": "1664178824",
        "timestamp": timestamp,
        "uid": this.userInfo.unid,
        "lang": "zh-cn"
      }

      for (let i = 0; i < p_PersonArr.length; i++)
      {
        let pre_PersonItem = p_PersonArr[i];
        console.log(pre_PersonItem)
        let skMap = {
          "username": pre_PersonItem.shortname,
          "key": "hcit",
          "path": "/qbgl/info?unid=" + this.formUnid
        }
        let sk = window.btoa(JSON.stringify(skMap))

        let sendMsgData = {
          "recver": [{
            "id": pre_PersonItem.unid,
            "name": pre_PersonItem.personCommonname
          }],
          "ctype": "3",
          "refer": {
            "id": this.userInfo.unid,
            "name": this.userInfo.personCommonname,
            "avatar": "https:\/\/gss0.bdstatic.com\/7Ls0a8Sm1A5BphGlnYG\/sys\/portrait\/item\/58f4baecc9abc1d4c8cb676578696e4627.jpg"
          },
          "flag": "2",
          "content": "",
          "extdata": {
            "header": [{
              "title": "您有一条签报信息需处理！"
            }, {
              "title": formatDate(new Date(), "{y}-{m}-{d} {h}:{i}:{s}"),
              "color": "#999999",
              "size": "s"
            }],
            "body": [{
              "label": "公文类型",
              "title": "签报"
            }],
            "footer": {
              "title": "去处理"
            },
            "target": {
              "url_mobile": location.origin + process.env.VUE_APP_PUBLIC_PATH + "?sk=" + sk,
              "url_pc": location.origin + process.env.VUE_APP_PUBLIC_PATH + "?sk=" + sk,
              "opentype": "1"
            },
            "obj": {
              "type": "oa",
              "id": "1111"
            }
          }
        }

        request({
          url: window.HC_config.VUE_APP_QD_URL,
          method: 'POST',
          data: sendMsgData,
          noShowError: true,
          headers: _headers,
        }).then(result =>
        {

        })

      }
    },
    //刷新待办事项
    reloadDbsx()
    {
      //获取当前登录人的代表事项
      if (window.HC_config.VUE_APP_isShowDBSX)
      {
        getToDoList({ pageNo: 1, pageSize: 1000 }).then((res) =>
        {
          this.SET_DBSXNUM(res.result.totalCount);
        });
      }
    }
  },
};
</script>

<style lang="scss" scoped>
.tip-info {
  margin-bottom: 10px;
}

.flow-node-list {
  margin: 0 0 10px;
}

.choice-person-box {
  display: flex;

  .org-list {
    width: 250px;
    border: 1px solid #e6ebf5;
    border-radius: 4px;

    .org-search {
      width: 80%;
      margin: 20px 10px 0;
      height: 32px;

      ::v-deep .el-input__inner {
        border-radius: 100px;
      }
    }
  }

  .group-list {
    width: 200px;
    border: 1px solid #e6ebf5;
    border-radius: 4px;

    .org-search {
      width: 80%;
      margin: 20px 10px 0;
      height: 32px;

      ::v-deep .el-input__inner {
        border-radius: 100px;
      }
    }
  }

  .person-list {
    width: 250px;
    border: 1px solid #e6ebf5;
    border-radius: 4px;

    .person-item {
      display: block;
      line-height: 26px;
      padding-left: 25px;
    }
  }

  .search-input {
    width: 80%;
    margin: 20px 10px 0;
    height: 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;

    ::v-deep .el-input__inner {
      border-radius: 100px;
    }
  }
}

.scorll-Y {
  height: 350px;
  margin-top: 10px;

  ::v-deep .el-scrollbar__wrap {
    overflow-x: hidden;
  }
}

.msg-check {
  margin-top: 5px;
}

.send_group_title {
  padding-left: 16px;
}

.btn-person-cacle {
  cursor: pointer;
  color: red;
  font-size: 14px;
}
</style>